<?php


abstract class BaseDireccion extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_direccion;


	
	protected $cf_ciudad;


	
	protected $cf_estudiante;


	
	protected $barrio;


	
	protected $urbanizacion;


	
	protected $avenida;


	
	protected $calle;


	
	protected $carrera;


	
	protected $vereda;


	
	protected $edificio_casa;


	
	protected $sector;


	
	protected $numero_apartamento;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpDireccion()
	{

		return $this->cp_direccion;
	}

	
	public function getCfCiudad()
	{

		return $this->cf_ciudad;
	}

	
	public function getCfEstudiante()
	{

		return $this->cf_estudiante;
	}

	
	public function getBarrio()
	{

		return $this->barrio;
	}

	
	public function getUrbanizacion()
	{

		return $this->urbanizacion;
	}

	
	public function getAvenida()
	{

		return $this->avenida;
	}

	
	public function getCalle()
	{

		return $this->calle;
	}

	
	public function getCarrera()
	{

		return $this->carrera;
	}

	
	public function getVereda()
	{

		return $this->vereda;
	}

	
	public function getEdificioCasa()
	{

		return $this->edificio_casa;
	}

	
	public function getSector()
	{

		return $this->sector;
	}

	
	public function getNumeroApartamento()
	{

		return $this->numero_apartamento;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpDireccion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_direccion !== $v) {
			$this->cp_direccion = $v;
			$this->modifiedColumns[] = DireccionPeer::CP_DIRECCION;
		}

	} 
	
	public function setCfCiudad($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_ciudad !== $v) {
			$this->cf_ciudad = $v;
			$this->modifiedColumns[] = DireccionPeer::CF_CIUDAD;
		}

	} 
	
	public function setCfEstudiante($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_estudiante !== $v) {
			$this->cf_estudiante = $v;
			$this->modifiedColumns[] = DireccionPeer::CF_ESTUDIANTE;
		}

	} 
	
	public function setBarrio($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->barrio !== $v) {
			$this->barrio = $v;
			$this->modifiedColumns[] = DireccionPeer::BARRIO;
		}

	} 
	
	public function setUrbanizacion($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->urbanizacion !== $v) {
			$this->urbanizacion = $v;
			$this->modifiedColumns[] = DireccionPeer::URBANIZACION;
		}

	} 
	
	public function setAvenida($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->avenida !== $v) {
			$this->avenida = $v;
			$this->modifiedColumns[] = DireccionPeer::AVENIDA;
		}

	} 
	
	public function setCalle($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->calle !== $v) {
			$this->calle = $v;
			$this->modifiedColumns[] = DireccionPeer::CALLE;
		}

	} 
	
	public function setCarrera($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->carrera !== $v) {
			$this->carrera = $v;
			$this->modifiedColumns[] = DireccionPeer::CARRERA;
		}

	} 
	
	public function setVereda($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->vereda !== $v) {
			$this->vereda = $v;
			$this->modifiedColumns[] = DireccionPeer::VEREDA;
		}

	} 
	
	public function setEdificioCasa($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->edificio_casa !== $v) {
			$this->edificio_casa = $v;
			$this->modifiedColumns[] = DireccionPeer::EDIFICIO_CASA;
		}

	} 
	
	public function setSector($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->sector !== $v) {
			$this->sector = $v;
			$this->modifiedColumns[] = DireccionPeer::SECTOR;
		}

	} 
	
	public function setNumeroApartamento($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->numero_apartamento !== $v) {
			$this->numero_apartamento = $v;
			$this->modifiedColumns[] = DireccionPeer::NUMERO_APARTAMENTO;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = DireccionPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_direccion = $rs->getString($startcol + 0);

			$this->cf_ciudad = $rs->getString($startcol + 1);

			$this->cf_estudiante = $rs->getString($startcol + 2);

			$this->barrio = $rs->getString($startcol + 3);

			$this->urbanizacion = $rs->getString($startcol + 4);

			$this->avenida = $rs->getString($startcol + 5);

			$this->calle = $rs->getString($startcol + 6);

			$this->carrera = $rs->getString($startcol + 7);

			$this->vereda = $rs->getString($startcol + 8);

			$this->edificio_casa = $rs->getString($startcol + 9);

			$this->sector = $rs->getString($startcol + 10);

			$this->numero_apartamento = $rs->getString($startcol + 11);

			$this->estatus = $rs->getString($startcol + 12);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 13; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Direccion object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DireccionPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			DireccionPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(DireccionPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = DireccionPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpDireccion($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += DireccionPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = DireccionPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DireccionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpDireccion();
				break;
			case 1:
				return $this->getCfCiudad();
				break;
			case 2:
				return $this->getCfEstudiante();
				break;
			case 3:
				return $this->getBarrio();
				break;
			case 4:
				return $this->getUrbanizacion();
				break;
			case 5:
				return $this->getAvenida();
				break;
			case 6:
				return $this->getCalle();
				break;
			case 7:
				return $this->getCarrera();
				break;
			case 8:
				return $this->getVereda();
				break;
			case 9:
				return $this->getEdificioCasa();
				break;
			case 10:
				return $this->getSector();
				break;
			case 11:
				return $this->getNumeroApartamento();
				break;
			case 12:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DireccionPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpDireccion(),
			$keys[1] => $this->getCfCiudad(),
			$keys[2] => $this->getCfEstudiante(),
			$keys[3] => $this->getBarrio(),
			$keys[4] => $this->getUrbanizacion(),
			$keys[5] => $this->getAvenida(),
			$keys[6] => $this->getCalle(),
			$keys[7] => $this->getCarrera(),
			$keys[8] => $this->getVereda(),
			$keys[9] => $this->getEdificioCasa(),
			$keys[10] => $this->getSector(),
			$keys[11] => $this->getNumeroApartamento(),
			$keys[12] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = DireccionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpDireccion($value);
				break;
			case 1:
				$this->setCfCiudad($value);
				break;
			case 2:
				$this->setCfEstudiante($value);
				break;
			case 3:
				$this->setBarrio($value);
				break;
			case 4:
				$this->setUrbanizacion($value);
				break;
			case 5:
				$this->setAvenida($value);
				break;
			case 6:
				$this->setCalle($value);
				break;
			case 7:
				$this->setCarrera($value);
				break;
			case 8:
				$this->setVereda($value);
				break;
			case 9:
				$this->setEdificioCasa($value);
				break;
			case 10:
				$this->setSector($value);
				break;
			case 11:
				$this->setNumeroApartamento($value);
				break;
			case 12:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = DireccionPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpDireccion($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCfCiudad($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCfEstudiante($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setBarrio($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setUrbanizacion($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setAvenida($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCalle($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setCarrera($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setVereda($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setEdificioCasa($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setSector($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setNumeroApartamento($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setEstatus($arr[$keys[12]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(DireccionPeer::DATABASE_NAME);

		if ($this->isColumnModified(DireccionPeer::CP_DIRECCION)) $criteria->add(DireccionPeer::CP_DIRECCION, $this->cp_direccion);
		if ($this->isColumnModified(DireccionPeer::CF_CIUDAD)) $criteria->add(DireccionPeer::CF_CIUDAD, $this->cf_ciudad);
		if ($this->isColumnModified(DireccionPeer::CF_ESTUDIANTE)) $criteria->add(DireccionPeer::CF_ESTUDIANTE, $this->cf_estudiante);
		if ($this->isColumnModified(DireccionPeer::BARRIO)) $criteria->add(DireccionPeer::BARRIO, $this->barrio);
		if ($this->isColumnModified(DireccionPeer::URBANIZACION)) $criteria->add(DireccionPeer::URBANIZACION, $this->urbanizacion);
		if ($this->isColumnModified(DireccionPeer::AVENIDA)) $criteria->add(DireccionPeer::AVENIDA, $this->avenida);
		if ($this->isColumnModified(DireccionPeer::CALLE)) $criteria->add(DireccionPeer::CALLE, $this->calle);
		if ($this->isColumnModified(DireccionPeer::CARRERA)) $criteria->add(DireccionPeer::CARRERA, $this->carrera);
		if ($this->isColumnModified(DireccionPeer::VEREDA)) $criteria->add(DireccionPeer::VEREDA, $this->vereda);
		if ($this->isColumnModified(DireccionPeer::EDIFICIO_CASA)) $criteria->add(DireccionPeer::EDIFICIO_CASA, $this->edificio_casa);
		if ($this->isColumnModified(DireccionPeer::SECTOR)) $criteria->add(DireccionPeer::SECTOR, $this->sector);
		if ($this->isColumnModified(DireccionPeer::NUMERO_APARTAMENTO)) $criteria->add(DireccionPeer::NUMERO_APARTAMENTO, $this->numero_apartamento);
		if ($this->isColumnModified(DireccionPeer::ESTATUS)) $criteria->add(DireccionPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(DireccionPeer::DATABASE_NAME);

		$criteria->add(DireccionPeer::CP_DIRECCION, $this->cp_direccion);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpDireccion();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpDireccion($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCfCiudad($this->cf_ciudad);

		$copyObj->setCfEstudiante($this->cf_estudiante);

		$copyObj->setBarrio($this->barrio);

		$copyObj->setUrbanizacion($this->urbanizacion);

		$copyObj->setAvenida($this->avenida);

		$copyObj->setCalle($this->calle);

		$copyObj->setCarrera($this->carrera);

		$copyObj->setVereda($this->vereda);

		$copyObj->setEdificioCasa($this->edificio_casa);

		$copyObj->setSector($this->sector);

		$copyObj->setNumeroApartamento($this->numero_apartamento);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpDireccion(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new DireccionPeer();
		}
		return self::$peer;
	}

} 